Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for...of loops #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Allow for...of loops #7

wants to merge 2 commits into from

Conversation

stevehanson
Copy link
Contributor

@stevehanson stevehanson commented Nov 10, 2023

This rule originally comes from the Airbnb ruleset. These were restricted by Airbnb because browser support was lacking in 2018. Browser support for for...of is now at 97%. Additionally, not all of our users are writing for the browser. Finally, for...of loops are the simplest way to loop through arrays asynchronously in sequence:

// this works, but .forEach and for...in do not
for await (const item of items) {
  await doSomething(item);
}

Similarly, this PR allows the use of continue statements. We often encourage early returns in methods, and to me continue is a similar concept, but in the context of a loop. I don't see a need to be opinionated about its usage.

https://caniuse.com/?search=for...of

Stephen Hanson added 2 commits November 9, 2023 22:51
These were restricted because browser support was lacking in 2018. Browser support is now at 97%. Additionally, not all of our users are writing for the browser. Finally, for...of loops are the simplest way to loop through arrays asynchronously in sequence.

https://caniuse.com/?search=for...of
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant